package com.xx.interceptor;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;

import java.util.Map;

public class MyInterceptor extends MethodFilterInterceptor{

    protected String doIntercept(ActionInvocation invocation)
            throws Exception {
        /*判断是否登入*/
        ActionContext actionContext = invocation.getInvocationContext();
        Map<String, Object> session = actionContext.getSession();
        Object user = session.get("user");

        if(user == null){
            return "toLogin";
        }else{
            return invocation.invoke();
        }
    }
}
